package Entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ferrari
 */
@Entity
@Table(name = "hd_users")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HdUsers.findAll", query = "SELECT h FROM HdUsers h"),
    @NamedQuery(name = "HdUsers.findByCoUser", query = "SELECT h FROM HdUsers h WHERE h.coUser = :coUser"),
    @NamedQuery(name = "HdUsers.findByNmUser", query = "SELECT h FROM HdUsers h WHERE h.nmUser = :nmUser"),
    @NamedQuery(name = "HdUsers.findByDeSenhaUser", query = "SELECT h FROM HdUsers h WHERE h.deSenhaUser = :deSenhaUser"),
    @NamedQuery(name = "HdUsers.findByDeEmailUser", query = "SELECT h FROM HdUsers h WHERE h.deEmailUser = :deEmailUser")})
public class HdUsers implements Serializable {
    private static final long serialVersionUID = 1L;
    
    public static final String findByNmUser = "HdUsers.findByNmUser";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "co_user")
    private Integer coUser;
    @Column(name = "nm_user")
    private String nmUser;
    @Basic(optional = false)
    @Column(name = "de_senha_user")
    private String deSenhaUser;
    @Column(name = "de_email_user")
    private String deEmailUser;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "coUserResp")
    private List<HdChamados> hdChamadosList;
    @JoinColumn(name = "co_setor_user", referencedColumnName = "co_setor")
    @ManyToOne
    private HdSetores coSetorUser;
    @JoinColumn(name = "co_tipo_user", referencedColumnName = "co_tipo_user")
    @ManyToOne(optional = false)
    private HdTipoUser coTipoUser;

    public HdUsers() {
    }

    public HdUsers(Integer coUser) {
        this.coUser = coUser;
    }

    public HdUsers(Integer coUser, String deSenhaUser) {
        this.coUser = coUser;
        this.deSenhaUser = deSenhaUser;
    }

    public Integer getCoUser() {
        return coUser;
    }

    public void setCoUser(Integer coUser) {
        this.coUser = coUser;
    }

    public String getNmUser() {
        return nmUser;
    }

    public void setNmUser(String nmUser) {
        this.nmUser = nmUser;
    }

    public String getDeSenhaUser() {
        return deSenhaUser;
    }

    public void setDeSenhaUser(String deSenhaUser) {
        this.deSenhaUser = deSenhaUser;
    }

    public String getDeEmailUser() {
        return deEmailUser;
    }

    public void setDeEmailUser(String deEmailUser) {
        this.deEmailUser = deEmailUser;
    }

    @XmlTransient
    public List<HdChamados> getHdChamadosList() {
        return hdChamadosList;
    }

    public void setHdChamadosList(List<HdChamados> hdChamadosList) {
        this.hdChamadosList = hdChamadosList;
    }

    public HdSetores getCoSetorUser() {
        return coSetorUser;
    }

    public void setCoSetorUser(HdSetores coSetorUser) {
        this.coSetorUser = coSetorUser;
    }

    public HdTipoUser getCoTipoUser() {
        return coTipoUser;
    }

    public void setCoTipoUser(HdTipoUser coTipoUser) {
        this.coTipoUser = coTipoUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (coUser != null ? coUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HdUsers)) {
            return false;
        }
        HdUsers other = (HdUsers) object;
        if ((this.coUser == null && other.coUser != null) || (this.coUser != null && !this.coUser.equals(other.coUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.HdUsers[ coUser=" + coUser + " ]";
    }
    
}
